<template>
  <div class="CustomerManage">
    <div class="search">
      <el-form :inline="true" :model="search" class="demo-form-inline">
        <el-form-item label="输入搜索">
          <el-input
            v-model="search.key"
            placeholder="请输入设备名称"
          ></el-input>
        </el-form-item>
        <el-form-item label="输入时间">
          <el-date-picker
            v-model="search.time"
            format="yyyy-MM-dd"
            value-format="yyyy-MM-dd"
            type="daterange"
            range-separator="-"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            @change="chage"
          ></el-date-picker>
        </el-form-item>
        <el-form-item
          ><el-button type="primary" @click="onsubmit"
            >查询</el-button
          ></el-form-item
        >
      </el-form>
      <!-- <el-button class="ebtn" type="warning" @click="GotoPg(null, null)"
        >新增客户</el-button
      > -->
    </div>
    <el-table
      :data="ListData"
      stripe
      style="margin: 10px 20px; width: calc(100% - 40px)"
      :height="autoHeightTable"
      show-overflow-tooltip
    >
      <el-table-column
        label="序号"
        align="center"
      >
        <template slot-scope="scope">
          <span>{{ scope.$index + 1 }}</span>
        </template>
      </el-table-column>
      <el-table-column
        prop="applyTime"
        label="申请日期"
        align="center"
      >
        <template v-slot="scope">
              <span>
                {{formatTime(scope.row.applyTime)}}
              </span>
        </template>
      </el-table-column>
      <el-table-column
        prop="type"
        label="事由"
        align="center"
      >
        <template v-slot="scope">
          <span v-show="scope.row.type==10">采购合同</span>
          <span v-show="scope.row.type==11">采购订单</span>
          <span v-show="scope.row.type==12">采购退货</span>
          <span v-show="scope.row.type==14">销售合同</span>
          <span v-show="scope.row.type==15">销售订单</span>
          <span v-show="scope.row.type==16">开票审核</span>
          <span v-show="scope.row.type==17">付款审核</span>
        </template>
      </el-table-column>
      <el-table-column
        prop="userName"
        label="申请人"
        align="center"
      ></el-table-column>
      <el-table-column label="状态" align="center">
        <template v-slot="scope">
          <span v-show="scope.row.shengheStatus==1">待审核</span>
          <el-button v-show="scope.row.shengheStatus==2" type="text" size="medium" @click="getBOhui(scope.row.checkFolwId)">驳回</el-button>
<!--          <span v-show="scope.row.shengheStatus==2">驳回</span>-->
          <span v-show="scope.row.shengheStatus==3">已完成</span>
        </template>
      </el-table-column>
      <!--<el-table-column prop="expriedebt" label="到期欠款(元)" align="center"></el-table-column>
        <el-table-column prop="unexpriedebt" label="未到期欠款(元)" align="center"></el-table-column>
        <el-table-column prop="totalexpriedebt" label="欠款总额(元)" align="center"></el-table-column>-->
      <el-table-column label="操作" width="300" align="center">
        <template slot-scope="scope">
          <el-button size="small" type="primary" v-show="scope.row.shengheStatus==1" @click=" examine(scope.row.id,scope.row.type,isDetail=1,scope.row.checkFolwId) "
            >审核</el-button
          >
          <el-button type="text" size="small"  @click="examine(scope.row.id,scope.row.type,isDetail=2,scope.row.checkFolwId)"
            >详情</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      background
      layout="prev, pager, next"
      :current-page="current"
      :page-size="pagesize"
      @current-change="handleCurrentChange"
      :page-count="total"
    >
    </el-pagination>
    <el-dialog
      title="驳回详情"
      :visible.sync="dialog_bohuiliyou"
      width="50%"
      :modal-append-to-body="false">
      <ul :data="bohuilist" class="bohuizujian">
        <li>
          <span>审核日期</span>
          <el-input v-model="bohuilist.checkTime" style="width: 70%;" disabled></el-input>
        </li>
        <li>
          <span>审核人</span>
          <el-input v-model="bohuilist.userName" style="width: 70%;" disabled></el-input>
        </li>
        <li>
          <span>驳回理由</span>
          <el-input v-model="bohuilist.bohuiReason" style="width: 70%;" disabled></el-input>
        </li>
      </ul>
      <span slot="footer" class="dialog-footer">
    <el-button type="primary" @click="dialog_bohuiliyou = false">返 回</el-button>
  </span>
    </el-dialog>
  </div>
</template>
<script>
import axios from "axios";
export default {
  data() {
    return {
      search: { key: "", start: "", end: "" },
      ListData: [{}],
      total: 1,
      current: 1,
      pagesize: 10,
      isDetail: false,
      dialog_bohuiliyou:false,
      // edits: 1,
      // edit: true,
      bohuilist:{
        bohuiReason:"",
        checkTime:"",
        userName:"",
      },
    };
  },
  computed: {
    autoHeightTable() {
      return document.documentElement.scrollHeight - 251 - 78;
    },
  },
  created() {
    this.getList();
    // this.getlist(0);

  },
  methods: {
    getBOhui(checkflowId) {
      this.dialog_bohuiliyou = true
      axios("/JX_java/procurement/getCheckFlowDetails?checkFlowId=" + checkflowId).then((res) => {
        console.log(res)
        let relse = res.data.data
        this.bohuilist = relse
        console.log(this.bohuilist)
      })


    },
    // nublist(){
    //   this.edits += this.edits
    //   if (this.edits == 1) {
    //       this.edit = true
    //   } else {
    //     this.edit = false
    //   }
    // },
    examine(id, type, statue,checkFolwId) {
      // return
      if (type == 10) {//采购合同
        this.$router.push({
          path: "/ExaminePurchaseContract", query: {
            id: id,
            type: type,
            statue: statue,
            checkFolwId: checkFolwId,
          }
        })
      }
      if (type == 11) {//采购订单
        this.dialog_PurchaseOrder = true
        axios.get("/JX_java/procurement/caigoushenghe/getshengHeDetails?shengheMessageId=" + id + "&&checkFlowId=" + checkFolwId).then(res => {
        })
      }
      if (type == 12) {//采购退货管理
      }
      if (type == 14) {//销售合同审核
        this.$router.push({
          path: "/SaleContractsSH", query: {
            id: id,
            type: type,
            statue: statue,
            checkFlowId: checkFolwId,

          },
        })
      }
      if (type == 15) {//销售订单审核
        this.$router.push({
          path: "/OrderManagementSH", query: {
            id: id,
            type: type,
            statue: statue,
            checkFolwId: checkFolwId,


          }
        })
      }

      if (type == 16) {//开票审核
      }

      if (type == 17) {//付款审核
      }

    },
      //时间格式化
    formatTime(data){
      return data==null?"":data.substring(0, 10);
    },
    getList() {
      const json = {
        beginTime: this.search.start,
        endTime: this.search.end,
        key: this.search.key,
        pageNum: this.current,
        pageSize: this.pagesize,
      };
      const message = JSON.parse(localStorage.getItem("message"));
      axios
        .post(
          "/JX_java/sales/salesShenghe/getCaigouShenghe" ,
          json
        )
        .then((res) => {
          const relse = res.data.data.content
          console.log(relse,11111111111111)
          this.ListData = relse;
          this.total= res.data.data.totalPages
        });
    },
    // //详情
    // shenhexq() {
    //   this.$router.push({
    //     path: "/ExamineManagexq",
    //   });
    // },
    // //审核
    // shenhe() {
    //   this.$router.push({
    //     path: "/ExamineManagesh",
    //   });
    // },
    handleCurrentChange(e) {
      this.current = e;
      this.getList();
    },

    onsubmit() {
      this.getList();
    },

    chage(e) {
      if (e) {
        this.search.start = e[0];
        this.search.end = e[1];
      } else {
        this.search.start = "";
        this.search.end = "";
      }
    },
  },
};
</script>

<style lang="scss" scoped>
@import "@/assets/scss/base.scss";
.bohuizujian{
  display: flex;
  flex-wrap: wrap;
  li{
    width: 33%;
    padding-top: 10px;
    text-align: center;
    span{
      display: inline-block;
      width: 25%;
    }
  }
}
.CustomerManage .search {
  height: 50px;
  border-radius: 5px;
  background-color: #fff;
  padding-left: 20px;
  padding-top: 10px;
  margin: 0 20px;
}
.CustomerManage .demo-form-inline {
  display: inline-block;
}
.CustomerManage .el-pagination {
  margin-top: 15px;
  text-align: center;
}
.CustomerManage .ebtn {
  float: right;
  margin-right: 20px;
}
/*.nav {
  background: $white;
  height: 50px;
  margin-top: 10px;
  width: 98%;
  padding: 0 1%;
  .search_box {
    width: 98%;
    padding-top: 5px;
  }
}
.customer_box1 {
  margin-top: 10px;

}
.block {
  padding-top: 10px;
  text-align: center;
}*/
</style>
